home *** CD-ROM | disk | FTP | other *** search
/ Light ROM 1 / LIGHT-ROM 1 (Amiga Library Services)(1994).iso / ffdisks / d998.lha / TeXPrt / source / ParseArgs.c < prev    next >
C/C++ Source or Header  |  1994-04-05  |  7KB  |  147 lines

  1. /***************************************************************************
  2.  *                                                                         *
  3.  *  Filename : ParseArgs.c                                                 *
  4.  *                                                                         *
  5.  *  Description : Fetches and parses startup arguments from WB or a shell. *
  6.  *                                                                         *
  7.  ***************************************************************************
  8.  *                                                                         *
  9.  *                         Modification History                            *
  10.  *                                                                         *
  11.  *  Date      Author       Comments                                        *
  12.  * ----------------------------------------------------------------------  *
  13.  * 10.6.93    R.Bödi       Created.                                        *
  14.  * 15.2.94    R.Bödi       Due to changes in SAS/C 6.50 it was possible    *
  15.  *                         to merge parsing of CLI and WB arguments into   *
  16.  *                         a single routine (see _WBArgc and _WBargv       *
  17.  *                         variables defined in dos.h).                    *
  18.  *                                                                         *
  19.  ***************************************************************************
  20.  *                                                                         *
  21.  * Copyright © 1993-1994 Richard Bödi,  All rights reserved.               *
  22.  *                                                                         *
  23.  ***************************************************************************/
  24.  
  25. /*----------------------------- INCLUDES ----------------------------------*/
  26.  
  27. #include "TeXPrt.h"
  28. #include "TexPrt_protos.h"
  29. #include "TexPrt_globals.h"
  30.  
  31. /*-------------------------- GLOBAL DATA ----------------------------------*/
  32.  
  33. char  *Keywords[] = { "SHELL", "FILE", "APPICON" };
  34. char  *Switchs[]  = { "/K", "/K", "/K" };
  35.  
  36. /*------------------------------- CODE ------------------------------------*/
  37.  
  38. /***************************************************************************
  39.  *                                                                         *
  40.  *  Function name : ParseWB                                                *
  41.  *                                                                         *
  42.  *  Description : Gets the filename of the icon which has been clicked     *
  43.  *                first. This file is assumed to be the DVI file which     *
  44.  *                has to be printed. Also fetches and parses the ToolTypes *
  45.  *                from the TeXPrt icon.                                    *
  46.  *                Allowed tooltypes are :                                  *
  47.  *                   SHELL (Specifies the shell for the DVI printer driver *
  48.  *                          output, e.g. newshell CON:20/340/660/150).     *
  49.  *                   APPICON (Specifies the icon file for the AppIcon.)    *
  50.  *                                                                         *
  51.  ***************************************************************************
  52.  *                                                                         *
  53.  *  Synopsis : ParseWB (WBArgStr)                                          *
  54.  *                                                                         *
  55.  *  Parameters :                                                           *
  56.  *       (struct WBStartup **) WBArgStr : The WB argument string.          *
  57.  *                                                                         *
  58.  *  Return value : None                                                    *
  59.  *                                                                         *
  60.  ***************************************************************************/
  61.  
  62. void  ParseWB (struct WBStartup *WBArgStr)
  63.  
  64. {
  65. struct DiskObject   *DiskObj;
  66. struct WBArg        *WBArg;
  67. char                 Buffer[FMSIZE];
  68. char               **ToolArray;
  69.  
  70.  
  71. WBArg = WBArgStr->sm_ArgList;
  72.  
  73. if (WBArg->wa_Name)     // get tooltypes
  74.    if (DiskObj = GetDiskObject (WBArg->wa_Name))
  75.       {
  76.       ToolArray = (char **)DiskObj->do_ToolTypes;
  77.       stpcpy (Args.ArgStr[KW_SHELL], FindToolType (ToolArray, Keywords[KW_SHELL]));
  78.       stpcpy (Args.ArgStr[KW_APPICON], FindToolType (ToolArray, Keywords[KW_APPICON]));
  79.       FreeDiskObject (DiskObj);
  80.       }
  81.  
  82. WBArg++;
  83.  
  84. if (WBArg->wa_Lock)     // get filename
  85.    {
  86.    NameFromLock (WBArg->wa_Lock, Buffer, sizeof (Buffer));
  87.    strmfp (Args.ArgStr[KW_FILE], Buffer, WBArg->wa_Name);
  88.    }
  89. }
  90.  
  91.  
  92.  
  93. /***************************************************************************
  94.  *                                                                         *
  95.  *  Function name : ParseShell                                             *
  96.  *                                                                         *
  97.  *  Description : Parses the commandline for parameters.                   *
  98.  *                Allowed parameters are :                                 *
  99.  *                   SHELL/K (Specifies the shell for the DVI printer      *
  100.  *                            driver output, e.g. newshell CON://660/150). *
  101.  *                   FILE/K (Specifies the DVI File.)                      *
  102.  *                   APPICON/K (Specifies the icon file for the AppIcon.)  *
  103.  *                                                                         *
  104.  ***************************************************************************
  105.  *                                                                         *
  106.  *  Synopsis : ParseShell (NoOfArgs, Arg)                                  *
  107.  *                                                                         *
  108.  *  Parameters :                                                           *
  109.  *
  110.  *       (char **) Arg : The shell argument string.                        *
  111.  *                                                                         *
  112.  *  Return value : None                                                    *
  113.  *                                                                         *
  114.  ***************************************************************************/
  115.  
  116. void  ParseShell (int NoOfArgs, char **Arg)
  117.  
  118. {
  119. int            kword;
  120. struct RDArgs *RDArgs;
  121. char           Template[CMDSTRLENGTH];
  122.  
  123.  
  124. for (kword = 0, Template[0] = 0; kword < LAST_KW; kword++)
  125.    {
  126.    if (Template[0])
  127.       strcat (Template, ",");
  128.    strcat (Template, Keywords[kword]);
  129.    strcat (Template, Switchs[kword]);
  130.    }
  131.  
  132. if (RDArgs = ReadArgs (Template, Args.ArgPtr, NULL))
  133.    {
  134.    for (kword = 0; kword < LAST_KW; kword++)
  135.       if (Args.ArgPtr[kword])
  136.          stpcpy (Args.ArgStr[kword], (char *)Args.ArgPtr[kword]);
  137.    }
  138. else
  139.    PrintFault (IoErr (), "Error reading arguments");
  140.  
  141. FreeArgs (RDArgs);
  142. }
  143.  
  144.  
  145.  
  146. /*---------------------------- END OF FILE --------------------------------*/
  147.